<template>
    <div>
        <el-form :inline="true" class="demo-form-inline" v-model="searchForm">
            <el-form-item>
                <el-date-picker value-format="yyyy-MM-dd" type="date" placeholder="上报日期" v-model="searchForm.date" style="width: 100%;"></el-date-picker>
            </el-form-item>
            <el-form-item>
                <el-input
                        v-model="searchForm.username"
                        placeholder="用户名"
                        clearable
                ></el-input>

            </el-form-item>
            <el-form-item>
                <el-input
                        v-model="searchForm.status"
                        placeholder="状态"
                        clearable

                ></el-input>
            </el-form-item>
<!--              Name: '',
                    Id:null,
                    date:null,
                    IDNumber:"",
                    Color:"",
                    TestingResult:""-->
            <el-form-item>
                <el-input
                        v-model="searchForm.IDNumber"
                        placeholder="身份证"
                        clearable
                ></el-input>

            </el-form-item>

            <el-form-item>
                <el-input
                        v-model="searchForm.TestingResult"
                        placeholder="核酸检测结果"
                        clearable
                ></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="search" icon="el-icon-search"
                >查找</el-button
                >
            </el-form-item>
            <!-- <el-form-item>
              <el-button
                type="primary"
                @click="addDialogVisible = true"
                icon="el-icon-circle-plus-outline"
                >新增</el-button
              >
            </el-form-item> -->

            <el-form-item>


                <el-button type="info" @click="downloadExcel" icon="el-icon-download"
                >导出Excel</el-button
                >

            </el-form-item>
        </el-form>
        <el-table
                :data="tableData"
                style="width: 100%"
                :row-class-name="tableRowClassName">
            <el-table-column type="expand">
                <template slot-scope="props">
                    <el-form label-position="left" inline class="demo-table-expand">
                        <!--{
  "Color": "绿色",
  "IDNumber": "",
  "Name": "",
  "RequestId": "835fc7cf-6596-484c-9736-3932315c1e1d",
  "TestingInterval": "48小时",
  "TestingResult": "阴性",
  "TestingTime": "2022-07-19 22:27:22",
  "Time": "07月20日 10:31:11",
  "Vaccination": "已接种3针"
}-->
                        <el-form-item label="健康码颜色">
                            <span>{{ props.row.healthCode.Color }}</span>
                        </el-form-item>
                        <el-form-item label="身份证号：">
                            <span>{{ props.row.healthCode.IDNumber }}</span>
                        </el-form-item>
                        <el-form-item label="核酸间隔：">
                            <span>{{ props.row.healthCode.TestingInterval }}</span>
                        </el-form-item>
                        <el-form-item label="核酸结果：">
                            <span>{{ props.row.healthCode.TestingResult }}</span>
                        </el-form-item>
                        <el-form-item label="核酸时间：">
                            <span>{{ props.row.healthCode.TestingTime }}</span>
                        </el-form-item>
                        <el-form-item label="接种针数：">
                            <span>{{ props.row.healthCode.Vaccination }}</span>
                        </el-form-item>
                    </el-form>
                </template>
            </el-table-column>
            <el-table-column
                    prop="day"
                    label="日期"
                    >
            </el-table-column>

            <el-table-column
                    prop="username"
                    label="用户名"
                    >
            </el-table-column>
            <el-table-column
                    label="状态"
                    prop="status"

            >
            </el-table-column>
            <el-table-column
                    prop="morning"
                    label="上午体温"
                    >
            </el-table-column>
            <el-table-column
                    prop="noon"
                    label="中午体温"
                    >
            </el-table-column>
            <el-table-column
                    label="下午体温"
                    prop="night"

            >
            </el-table-column>

           <!-- <el-table-column
                    label="身份证号"
                    prop="IDNumber"
                    width="180"
            ></el-table-column>

            <el-table-column
                    label="核酸间隔时间"
                    prop="TestingInterval"
                    width="180"
            ></el-table-column>
            <el-table-column
                    label="核酸结果"
                    prop="TestingResult"
                    width="180"
            ></el-table-column>
            <el-table-column
                    label="更新时间"
                    prop="TestingTime"
                    width="180"
            ></el-table-column>
            <el-table-column
                    label="接种疫苗针数"
                    prop="Vaccination"
                    width="180"
            ></el-table-column>
            <el-table-column
                    label="健康码颜色"
                    prop="Color"
                    width="130"
            ></el-table-column>-->
        </el-table>
        <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="page.CurrentPage"
                :page-sizes="[10, 20, 50, 100]"
                :page-size="page.Size"
                layout="total, sizes, prev, pager, next, jumper"
                :total="page.Total"
        >
        </el-pagination>

        <!-- <el-dialog
          title="分配权限"
          :visible.sync="disDialogVisible"
          width="30%"

        >
        <el-form :model="TreeData">
        <el-tree
          :data="data"
          show-checkbox
          node-key="id"
          ref="AuthTree"
          default-expand-all
          check-strictly
          :props="defaultProps">
        </el-tree>
        </el-form>
        <span slot="footer" class="dialog-footer">
        <el-button @click="disDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="putData">确 定</el-button>
        </span>
        </el-dialog> -->
    </div>
</template>

<style>
    .el-table .warning-row {
        background: ivory;
        font-weight: bold;
        color: #ff7d34;
    }

    .el-table .success-row {
        background: mintcream;
        font-weight: bold;
        color: #7700ff;
    }
    .el-table .yichang-row{
        color: red;
        font-weight: bold;
    }
    .el-table .zhengchang{
        color: black;

    }
    .el-table .info-row {
        font-weight: bold;
    }
    .el-table{
        color: black;
    }
    .el-pagination {
        float: right;
    }
    .el-form {
        padding-right: 40px;
    }
    .el-button{
        margin-right: 7px;
        margin-left: 10px;
    }
</style>

<script>
    import { request } from "@/axios/request"
    export default {
        created(){
            this.getAll()
        },
        methods: {
            handleSizeChange(val) {
                this.page.Size=val
                this.getAll();
            },
            handleCurrentChange(val) {
                this.page.CurrentPage=val
                this.getAll();
            },


            changeSelect(id,status){
                console.log(id)
                console.log(status)

            },

            search(){
                this.getAll();
            },
            async getAll(){
                // eslint-disable-next-line no-undef
                this.$message('正在查询请稍后...');
              await  request({
                    url: "/temperatureAndHealthCode",
                    method: "get",
                    timeout: 60000,
                    params:{
                        date:this.searchForm.date,
                        name:this.searchForm.name,
                        status:this.searchForm.status,
                        idNumber:this.searchForm.IDNumber,
                        result:this.searchForm.TestingResult,
                        currentPage:this.page.CurrentPage,
                        size:this.page.Size,

                    }
                }).then(res => {
                    if(res.data.object.data==null){

                        this.page.Total=res.data.object.TotalCount;
                    }else{

                        this.tableData = res.data.object.data
                        this.page.Total=res.data.object.TotalCount;
                    }

                });
            },
            tableRowClassName({row, rowIndex}) {
                if (row.status != "正常"){
                    return "yichang-row";
                }else {
                    return "zhengchang-row"
                }



            }
        },
        data() {
            return {
                loading: true,
                test:[],
                tableData: [{
                    id:1,
                    day: '2016-05-02',
                    name: '王小虎',
                    status:"正常",
                    //*{"Name":"","IDNumber":"",
                    /*"Time":"07月20日 10:31:11",
                    "Color":"绿色","TestingInterval":"48小时",
                    "TestingResult":"阴性","TestingTime":"2022-07-19 22:27:22",
                    "Vaccination":"已接种3针","RequestId":"afbd2760-48ae-469d-ba7b-b5c4a6cbdcf2"}*!/*/
                    healthCode:{},
                    morning: "正常",
                    night: "正常",
                    noon: "正常",
                }, {
                    id:1,
                    day: '2016-05-02',
                    name: '王小虎',
                    status:"正常",
                    healthCode:{},
                    morning: "正常",
                    night: "正常",
                    noon: "正常",
                }, {
                    id:1,
                    day: '2016-05-02',
                    name: '王小虎',
                    status:"正常",
                    morning: "正常",
                    healthCode:{},
                    night: "正常",
                    noon: "正常",
                }, {
                    id:1,
                    day: '2016-05-02',
                    name: '王小虎',
                    status:"正常",
                    morning: "正常",
                    healthCode:{},
                    night: "正常",
                    noon: "正常",
                }],
                //applyDisabled:true,
                applyDate:["2020-02-01 19:00:00", "2020-02-01 20:00:00"],
                addForm: {
                    // id:null,
                    // name: "",
                    // code: "",
                    // remark:"",
                    // statu: "",

                },
                options: [
                    {
                        value: 1,
                        label: '报修成功'
                    }, {
                        value: 2,
                        label: '开始维修'
                    }, {
                        value: 3,
                        label: '维修完成'
                    }],

                areaForm:{
                    country:null,
                    province:null,
                    city:null,
                    district:null
                },
                status: null,
                editvalue:null,
                data: [],
                loading:false,
                TreeData:{},
                currentRoleId:null,
                addDialogVisible: false,
                //disDialogVisible:false,
                searchForm: {
                    Name: '',
                    Id:null,
                    date:null,
                    IDNumber:"",
                    Color:"",
                    TestingResult:"",
                    status:""

                },

                page: {
                    Size: 10,
                    CurrentPage: 1,
                    Total: null
                },
                selectIds:[],
                delButSta: true,

                rules: {
                    name: [
                        { required: true, message: "请输入角色名称", trigger: "blur" },
                        { min: 3, max: 8, message: "长度在 3 到 8 个字符", trigger: "blur" },
                    ],
                    code: [
                        { required: true, message: "请输入唯一状态码", trigger: "blur" },
                    ],
                    statu: [{ required: true, message: "请输入状态", trigger: "blur" }],
                },
                defaultProps: {
                    children: 'children',
                    label: 'name'
                },
            };
        }
    }
</script>
<style>

    .demo-table-expand {
        font-size: 0;
    }
    .demo-table-expand label {
        width: 90px;
        color: #99a9bf;
    }
    .demo-table-expand .el-form-item {
        margin-right: 0;
        margin-bottom: 0;
        width: 50%;
    }
</style>
